Integrating Flash Animations into RoboDemo Movies
Table of Contents
Interactive and Nonlinear Animations
Up until now the animations have been simple linear animations that play straight through from frame 1 to completion. RoboDemo can determine the duration of these animations by simply performing a frame count, and then control the playback of rest of the movie accordingly.
If you build user interaction into your animations or use ActionScript to affect how long the animations will play, RoboDemo will no longer be able to automatically determine when to remove the animation. You must therefore control playback yourself using ActionScript.
The first step is to decide whether you want to pause the RoboDemo movie or to continue playing it while your animation displays.
Pausing the RoboDemo Movie while Playing the Animation
Pausing the RoboDemo movie while the animation plays is easy; you simply instruct the animation to stop the RoboDemo movie when it starts playing and continue the RoboDemo movie when it finishes.
In this third example, you'll add some ActionScript to a Flash SWF file so it can control a RoboDemo movie, then you'll insert the SWF into the movie as an animation:
In Flash, open Example3_a.fla.
You'll see that this is basically the same as Example1_a.fla used in the first example, but I've added two new layers: one to display the shaking arrow, the second to hold the ActionScript.
Preview the movie by selecting Control > Test Movie.
You'll see that the shaking arrow fades in after the "Welcome" message displays, then the movie stops and waits for the user to click the arrow. In its current state, if you inserted it into a RoboDemo movie, it would simply play for 5 seconds, and then disappear.
You need to add some ActionScript at the start of the animation to stop the RoboDemo movie, then some at the end to restart the RoboDemo movie.
Click frame 1 of the Script layer and add the following ActionScript:
_parent.stop();
RoboDemo movie.swf consists of a collection of movie clips on
_root, which contain all the elements of the movie. These movie clips include:- rdpbHost_mc contains the slides, captions, etc, that compose the actual movie.
- rdInsertmc10002_mc contains the first inserted animation.
- rdPlay bar_mc contains all elements of the play bar.
Therefore
parent.stop()will stop the animation's parent movie clip, that is, the main RoboDemo movie contained in_root. This is the equivalent of_root.stop(), but as previously stated, don't use_rootunless you really know what you're doing.Click frame 95 of the Script layer and add the following ActionScript:
_parent.rdpbHost_mc.pbhForward();
This code triggers the
pbhForward()function which normally executes when a user presses the forward button on the play bar. This causes the RoboDemo movie to jump to the next slide and restarts playback.You could have issued a
_parent.play()command, however, in this case it would cause a short delay before moving to the next frame as the playhead waits for any remaining objects on the slide to play.Other useful play bar functions include:
_parent.rdpbHost_mc.pbhForward() // Press the Forward button. _parent.rdpbHost_mc.pbhPause() // Press the Pause button. _parent.rdpbHost_mc.pbhPlay() // Press the Play button. _parent.rdpbHost_mc.pbhBack() // Press the Back button. _parent.rdpbHost_mc.pbhRewind() // Press the Rewind button. _parent.rdpbHost_mc.pbhInfo() // Press the Info button. _parent.rdpbHost_mc.pbhExit() // Press the Exit button.
Note: The play bar functions are available whether the movie uses a play bar or not.
Notice there is a frame 100 after our ActionScript on frame 95. This is required because RoboDemo fails to play the last frame of an inserted animation. If frame 95 were the last frame of our animation, our ActionScript would not execute, and the main RoboDemo movie would fail to restart.
- Now you can save the file (File > Save) and export it as Example3_a.swf (File > Export Movie).
- In RoboDemo, open Example3_rd.rd.
- Double-click slide 3 to open it in the Edit window.
- Select Insert > Animation, then navigate to and open Example3_a.swf.
- Leave all options at their defaults and press OK.
- Drag the sizing handle at the top of the animation down slightly to resize the animation to 400 x 270 pixels. This prevents the welcome message from displaying too close to the caption "Slide 3."
Now you can save the file (File > Save) and preview it (File > Preview).
Notice how the slider on the play bar stops moving when the animation displays, then restarts once the animation has finished.
Now you'll have a look at how you can display the animation over multiple frames.
Playing the RoboDemo Movie and Animation Concurrently
Having the RoboDemo movie continue playing while the interactive animation is displaying is slightly more difficult. This is because RoboDemo removes an animation after it has played once—so a five-frame animation will only display for one-quarter of a second. This is not very useful if you need your animation to display on every frame of your movie.
Fortunately you can use ActionScript to get around this issue by having the animation duplicate itself to a new movie clip. Then, when the original animation is removed, the new movie clip remains.
In Flash, open Example4_a.fla.
You'll see that the animation again uses three layers: one to display the information icon, the second to display the caption, and the third to hold your ActionScript.
Preview the movie by selecting Control > Test Movie.
You'll see the information icon displayed; rolling over it displays the caption, rolling out hides the caption.
Now you need to add ActionScript to duplicate the animation so it will continue to play throughout the RoboDemo movie.
Click frame 1 of the Script layer and add the following ActionScript before the existing code:
if (this._target.indexOf("rdInsert") != -1) { duplicateMovieClip(this, "myClip", 1); }It should now read:
if (this._target.indexOf("rdInsert") != -1) { duplicateMovieClip(this, "myClip", 1); } Text._visible=false; stop();The
ifstatement at the start of the code tests the name of the movie clip to see if it's the original animation or the duplicate. If the name begins withrdInsert, it's the original and needs to be duplicated and namedmyClip.After the code creates
myClip, theifstatement runs again. However, this time the movie clip name doesn't begin withrdInsert, so the movie clip is not duplicated.You don't need to add any code to remove
myClipbecause you want it to display on every slide of the movie.- Now you can save the file (File > Save) and export it as Example4_a.swf (File > Export Movie).
- In RoboDemo, open Example4_rd.rd.
- Double-click slide 1 to open it in the Edit window.
- Select Insert > Animation, then navigate to and open Example4_a.swf.
- Leave all options at their defaults and press OK.
- Drag the animation down to the lower right corner.
- Now save the file (File > Save) and preview it (File > Preview).